import request from '@/utils/request'
// 注册接口
export const registerAPI = (data) => {
  return request({ url: '/api/register', method: 'post', data })
}
// 登录接口
export const loginAPI = (data) => {
  return request({ url: '/api/login', method: 'post', data })
}

export const initAPI = () => {
  return request({ url: '/init/data' })
}
// 查询所有学生
export const getStudentAPI = () => {
  return request({ url: '/student/list' })
}
// 删除
export const deleteStudentAPI = (id) => {
  return request({ url: '/student/delete', method: 'delete', params: { id } })
}
// 添加
export const addStudentAPI = (form) => {
  return request({
    url: '/student/add',
    method: 'post',
    data: {
      ...form,
      group: Math.floor(Math.random() * 8 + 1)
    }
  })
}
// 查询某个学员
export const getStudentByIDAPI = (id) => {
  return request({ url: '/student/one', params: { id } })
}

// 修改某个学员
export const updataStudentByIDAPI = (form) => {
  // 根据需求去经纬度，那边不好改在这边改
  delete form.user_id
  delete form.jing
  delete form.wei
  return request({
    url: '/student/update',
    method: 'put',
    data: {
      ...form
    }
  })
}
// 省
export const getProvinceAPI = () => {
  return request({ url: 'geo/province' })
}
// 市
export const getCityAPI = (pname) => {
  return request({ url: '/geo/city', params: { pname } })
}
// 区
export const getCountyAPI = (pname, cname) => {
  return request({ url: '/geo/county', params: { pname, cname } })
}
